Fk:loadTranslationTable{
  ["dajubei__anmou_active"] = "暗谋",
  ["#dajubei__anmou_active"] = "暗谋：将扣置牌当 %arg 使用或弃置",
}

local anmou = fk.CreateSkill{
  name = "dajubei__anmou_active"
}

anmou:addEffect("active", {
  prompt = function (self, player)
    return "#dajubei__anmou_active:::" .. Fk:translate(self.cardName)
  end,
  can_use = Util.FalseFunc,
  expand_pile = function (self, player)
    return player:getPile("$dajubei__anmou_pile")
  end,
  interaction = function (self, player)
    local choices = {self.cardName, "discard"}
    return UI.ComboBox{ choices = choices, all_choices = choices }
  end,
  card_filter = function (self, player, to_select, selected)
    return table.contains(player:getPile("$dajubei__anmou_pile"), to_select)
  end,
  target_filter = function (self, player, to_select, selected, selected_cards)
    if not self.interaction.data or self.interaction.data == "discard" then return false end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcards(selected_cards)
    card.skillName = "dajubei__anmou"
    return #selected < card.skill.max_target_num and card.skill:targetFilter(player, to_select, selected, selected_cards, card, {bypass_times = true})
  end,
  feasible = function (self, player, selected, selected_cards)
    if #selected_cards ~= #player:getPile("$dajubei__anmou_pile") then return false end
    if self.interaction.data == "discard" then
      return true
    elseif self.interaction.data == self.cardName then
      local card = Fk:cloneCard(self.interaction.data)
      card:addSubcards(selected_cards)
      card.skillName = "dajubei__anmou"
      if not player:canUse(card, { bypass_times = true }) then return false end
      if card.skill.target_num then
        return #selected == card.skill.target_num
      else
        return #selected <= card.skill.max_target_num and #selected >= card.skill.min_target_num
      end
    else
      return false
    end
  end
})

return anmou